package myJs

import myJs.Utils._
import myJs.myPkg._
import myJs.myPkg.jquery._
import shared.Implicits._
import shared.Shared

import scala.scalajs.js
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}


/**
  * Created by yz on 2019/4/15
  */
@JSExportTopLevel("MyTool")
object MyTool {

  var score: BigDecimal = _
  var result: String = _

  @JSExport("init")
  def init = {

  }

  @JSExport("dealDanger")
  def dealDanger(extraDataJson: js.Dictionary[js.Any]) = {
    if (extraDataJson.myGet("danger") == "") {
      val danger = Shared.getDanger(score)
      $("#exportForm textarea[name='danger']").`val`(danger)
    } else {
      $("#exportForm textarea[name='danger']").`val`(extraDataJson.myGet("danger"))
    }

    $(":input[name='score']").`val`(score.toString())
    $(":input[name='result']").`val`(result)
    $(":input[name='svgStr']").`val`($("#svg1").html())
  }

}
